const path = require('path');
const express = require('express');
const router = express.Router();
const { buildFileTree } = require('../utils/handleFile')

// 测试 MongoDB 连接
router.get('/file-tree', async (req, res) => {
  try {
    const fileTree = buildFileTree(path.join(__dirname, '../shoreFile'));
    res.json({
      code: 0,
      message: 'success',
      data: fileTree
    });
  } catch (err) {
    res.json({
      code: 1,
      message: err.message
    });
  }
});

module.exports = router;